#ifndef L2CDTP_HPP
#define L2CDTP_HPP

#include <stdint.h>

namespace L2CDTP {

const unsigned int MAX_FRAME_SIZE = 512;

const uint8_t TYPE_COMMAND = 0x00;
const uint8_t TYPE_DATA = 0x01;

const uint8_t FLAG_DATATYPE_MASK = 0x03;
const uint8_t FLAG_DATATYPE_BOOLEAN = 0x01;
const uint8_t FLAG_DATATYPE_NUMBER = 0x02;
const uint8_t FLAG_DATATYPE_STRING = 0x03;

const uint8_t FLAG_RW_MASK = 0x80;
const uint8_t FLAG_READ = 0x00;
const uint8_t FLAG_WRITE = 0x80;

const uint8_t FLAG_SUCCESS = 0x01;
const uint8_t FLAG_FAILED = 0x00;

typedef struct FrameHeader {
    uint8_t type;
    uint8_t flag;
    uint16_t extra;
    uint16_t label_length;
    uint16_t data_length; 
} FrameHeader_t;

typedef struct CommandRequest {
    const char *command_label;
    uint8_t extra_data;
    const char *bundle_data;
    unsigned int bundle_data_size;
} CommandRequest_t;

typedef struct CommandResponse {
    uint8_t extra_data;
    char *bundle_data;
    unsigned int bundle_data_size;
} CommandResponse_t;

typedef struct DataRequest {
    const char *data_label;
    uint8_t rw;
    uint8_t type;
    uint8_t extra_data;
    const void *data;
    unsigned int data_size;
} DataRequest_t;

typedef struct DataResponse {
    uint8_t extra_data;
    void *data;
    unsigned int data_size;
} DataResponse_t;

}

#endif